<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<link href="css/site.css" rel="stylesheet" type="text/css" />
<title>New Post</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="850px" border="0">
    <tr>
  
     <th style="text-align:left; padding:10px;"><label for="title">Tiêu đề</label>
      &nbsp;&nbsp;&nbsp;
     <input type="text" class="title3" name="txtTitle" id="txtTitle" /></th>
    </tr>
   
    <tr>
      <td colspan="2">
      	<textarea cols="100" id="txtContent" name="txtContent" rows="10"></textarea>
		<script type="text/javascript">
				var editor = CKEDITOR.replace( 'txtContent' );
		</script>
      </td>
    </tr>
      <tr> 
       <td colspan="2" style="text-align:center;">
       	 <input class="button1" type="submit" name="btnPost" id="btnPost" value="Đăng bài" />&nbsp; &nbsp;&nbsp;&nbsp;
         <input class="button1" type="reset" name="btnHuy" id="btnHuy" value="Hủy bỏ" />
        </td>
    </tr>
  </table>
  <?php
	if(isset($_POST["btnPost"]))
	{
		include_once("config/database.php");
		include_once("config/util.php");
		$title = mysql_real_escape_string($_POST["txtTitle"]);
		$content = mysql_real_escape_string($_POST["txtContent"]);
		$db = new database();
		$array = array('title'=>$title, 'content'=>$content, 'date_created' => date("yyyy-MM-dd"));
		$db->insertRows("posts",$array);
		showMessage("Đăng thành công!");
	}
?>
</form>

</body>
</html>